package com.liuxin.zhiyuan.shujuzhongxin.service.impl;

import com.liuxin.zhiyuan.shujuzhongxin.domain.dto.RecruitMajorDTO;
import com.liuxin.zhiyuan.shujuzhongxin.mapper.RecruitMajorInfoMapper;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liuxin.common.utils.PageUtils;
import com.liuxin.common.utils.Query;

import com.liuxin.zhiyuan.shujuzhongxin.domain.po.RecruitMajorInfoEntity;
import com.liuxin.zhiyuan.shujuzhongxin.service.RecruitMajorInfoService;

@Service
public class RecruitMajorInfoServiceImpl extends ServiceImpl<RecruitMajorInfoMapper, RecruitMajorInfoEntity> implements RecruitMajorInfoService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<RecruitMajorInfoEntity> page = this.page(
                new Query<RecruitMajorInfoEntity>().getPage(params),
                new QueryWrapper<RecruitMajorInfoEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public List<RecruitMajorInfoEntity> getUnprocessedRecords() {
        // 查询未处理的记录（processed_time为null或为空）
        QueryWrapper<RecruitMajorInfoEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.isNull("processed_time");
        queryWrapper.in("batch_id",2510,1530);
        queryWrapper.eq("id",42389);
        queryWrapper.last(" limit 1 ");
        return this.list(queryWrapper);
    }

    @Override
    public int batchUpdatePrediction(List<RecruitMajorInfoEntity> records) {
        int count = 0;
        Date now = new Date();
        for (RecruitMajorInfoEntity record : records) {
            count += baseMapper.updatePrediction(record.getId(), record.getYcPaiming(), record.getYcScore(), now);
        }
        return count;
    }

     @Override
    public List<RecruitMajorDTO> queryRecruitMajorList(
            Integer schoolId,
            String nature,
            String schoolCode) {
        return baseMapper.queryRecruitMajorList(schoolId, nature, schoolCode);
    }
}
